package z_exam;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: 海琳琦
 * @Date: 2022/8/17 20:12
 */
public class Test11 {

    public static Object stati() {
        InputStreamReader isr = null;
        Map<Integer, Long> hash = new HashMap<>();
        try {
            isr = new InputStreamReader(new
                    FileInputStream("D:\\idea项目\\Algorithm-plus\\src\\main\\java\\test.txt"));
            char[] chs = new char[8];
            int len;

            while ((len = isr.read(chs)) != -1) {
                String[] s = new String(chs, 0, len).split(",");
                for (String age : s) {
                    Integer integer = Integer.valueOf(age);
                    if (hash.containsKey(integer)) {
                        hash.put(integer, hash.get(integer) + 1);
                    }else{
                        hash.put(integer, 1L);
                    }
                }
            }
            isr.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return hash;
    }

    public static void main(String[] args) throws IOException {
        InputStream stram = new FileInputStream("D:\\idea项目\\Algorithm-plus\\src\\main\\java\\test.txt");
        byte[] b = new byte[8];
        int len = stram.read(b);
        System.out.println(len);
    }
}
